<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
	include 'project_panel.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-list"></i> <?php echo $this->pTitle;?></div>
				</div>
				<div class="panel-body">
					<form action="javascript:projectFilter();" class="form-inline">
						<input type="text" class="form-control" placeholder="Tiêu đề / mã hợp đồng" id="search_tieude" name="tieude" value="<?php echo $_GET['tieude'];?>">
						<input type="text" name="ngayStart" id="datepicker" class="form-control date_picker" placeholder="<?php echo $this->language['project_start_date'];?>" value="<?php echo $_GET['ngaystart'];?>" />
						<input type="text" name="ngayEnd" id="datepicker1" class="form-control date_picker" placeholder="<?php echo $this->language['project_end_date'];?>" value="<?php echo $_GET['ngayend'];?>" />
						<select class="form-control" id="statusFilter" name="status">
							<option value="">Tất cả Tình trạng</option>
							<option value="0" <?php echo ($_GET['status'] == "0") ? "selected" : "";?>>Đang chờ</option>
							<option value="1" <?php echo ($_GET['status'] == 1) ? "selected" : "";?>>Đang xử lý</option>
							<option value="2" <?php echo ($_GET['status'] == 2) ? "selected" : "";?>>Đã giao</option>
							<option value="3" <?php echo ($_GET['status'] == 3) ? "selected" : "";?>>Hoàn thành</option>
							<option value="5" <?php echo ($_GET['status'] == 5) ? "selected" : "";?>>Đã quá hạn</option>
							<option value="-1" <?php echo ($_GET['status'] == -1) ? "selected" : "";?>>Đã từ chối</option>
						</select>
						<button class="btn btn-danger" type="submit"><i class="icon-search"></i> <?php echo $this->language['search'];?></button>
					</form>
					<table class="table table-fixed table-hover table-condensed">
						<thead>
							<tr>
								<th width="75px"><?php echo $this->language['project_code'];?></th>
								<th width="140px">Mã hợp đồng</th>
								<th><?php echo $this->language['project_name'];?></th>
								<th width="130px"><?php echo $this->language['project_end_date'];?></th>
								<th width="110px"><?php echo $this->language['status'];?></th>
								<th width="100px"><?php echo $this->language['creator'];?></th>
							</tr>
						</thead>
						<tbody>
						<?php foreach($this->items as $data) {?>
							<tr style="border-bottom:1px solid #d5d4d4">
								<td><a href='#project_view/pid=<?php echo $data['pId'];?>' <?php echo ($data['pQToan']) ? 'title="Đã quyết toán"' :'style="color:#F00;" title="Chưa quyết toán"' ;?>><?php echo $data['pCode'];?></a></td>
								<td><?php echo $data['pContract'];?></td>
								<td><a href='#project_view/pid=<?php echo $data['pId'];?>'><?php echo $data['pName'];?></a></td>
								<td>
									<?php
										if($data['pStatus'] < 3 && $data['pStatus'] >= 0){
											if($data['pDeadTime'] <= time()) echo "<font color=red>".date("d/m/Y",$data['pDeadTime'])."</font>";
											else echo date("d/m/Y",$data['pDeadTime']);
										}
										else echo date("d/m/Y",$data['pDeadTime']);
									?>
								</td>
								<td class="text-center">
									<?php
										if($data['pStatus']==0) echo "<span class='label label-waiting'>".$this->language['waiting']."</span>";
										elseif($data['pStatus']==1) echo "<span class='label label-process'>".$this->language['processing']."</span>";
										elseif($data['pStatus']==2) echo "<span class='label label-preview'>".$this->language['testing']."</span>";
										elseif($data['pStatus']==3 || $data['pStatus']==4) echo "<span class='label label-complete'>".$this->language['completed']."</span>";
										elseif($data['pStatus']==-1) echo "<span class='label label-deny'>".$this->language['cancelled']."</span>";
										else echo $this->language['unknown'];
									?>
								</td>
								<td>
									<?php echo $_SESSION['user_data'][$data['pCreateUser']]['fullname'];?>
								</td>
							</tr>
						<?php } ?>
						</tbody>
						<tfoot>
							<tr>
								<td colspan=6>
									<?php if(isset($this->pagination))echo $this->pagination; ?>
								</td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="resources/scripts/jquery-ui.min.js"></script>
	<script type="text/javascript" src="resources/scripts/jquery.datePicker.js"></script>
	<script>
	$(function() {
		$( "#datepicker1" ).datepicker({dateFormat: 'dd-mm-yy'});
		$( "#datepicker" ).datepicker({dateFormat: 'dd-mm-yy'});
	});
	</script>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>